<!-- 1 脚本 -->
<script lang="ts" setup name="ToDoItem">
const { id, title, dealDown } = defineProps<{
  id: string
  title: string
  done: boolean
  dealDown?: (id: string) => void
}>()

function deal() {
  if (dealDown) {
    dealDown(id)
  }
}
</script>

<!-- 2 模板 -->
<template>
  <div class="item">
    <div class="title">{{ title }}</div>
    <div v-if="done">
      <el-button type="success" circle>
        <el-icon><Select /></el-icon>
      </el-button>
    </div>
    <div v-else>
      <el-button type="danger" circle @click="deal">
        <el-icon>
          <Close />
        </el-icon>
      </el-button>
    </div>
  </div>
</template>

<!-- 3 样式 -->
<style scoped>
.item {
  margin: 5px;
  padding: 5px;
  width: 400px;
  display: flex;
  border-bottom: solid 1px grey;

  .title {
    width: 370px;
  }
}
</style>
